<template>
  <!-- 风险地区 -->
  <div class="area">
    <nav-bar>
      <div slot="left" @click="goback">
        <span class="iconfont goback">&#xe600;</span>
      </div>
      <div slot="center"><h2>全国风险地区汇总</h2></div>
    </nav-bar>
    <div class="bg">
      <div class="content">
        <div class="th">
          <p><span>全国风险地区汇总</span></p>
        </div>
        <!-- 1、高风险区 -->
        <template v-if="high.length > 0">
          <div class="title">
            <img src="../../../assets/images/high.png" alt="" />
            高风险区{{ high.length }}个
          </div>
          <ul class="list">
            <li v-for="(item, index) in high" :key="index">
              {{ item }}
            </li>
          </ul>
        </template>

        <!-- 2、中风险区 -->
        <template v-if="mid.length > 0">
          <div class="title">
            <img src="../../../assets/images/mid.png" alt="" />
            中风险区{{ mid.length }}个
          </div>
          <ul class="list">
            <li v-for="(item, index) in mid" :key="index">
              {{ item }}
            </li>
          </ul>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
import NavBar from "../../../components/NavBar.vue";
export default {
  name: "Area",
  components: {
    NavBar,
  },
  // 定义属性
  data() {
    return {
      high: [], //高风险区数据
      mid: [], //低风险区
    };
  },
  created() {
    this.$api.getCovidInfo().then((res) => {
      console.log(res.data.newslist[0]);
      let riskarea = res.data.newslist[0].riskarea;
      // 解析
      this.high = riskarea.high; //全国高风险地区
      this.mid = riskarea.mid; //全国中风险地区
    });
  },
  methods: {
    goback() {
      return history.back();
    },
  },
};
</script>

<style scoped lang="less">
.area {
  border-top: 1px solid #eee;

  padding-bottom: 0.4rem;
  background: #f5f5f5;
  .goback {
    font-size: 0.5rem;
    vertical-align: middle;
    color: rgb(78, 110, 242);
  }
  h2 {
    font-size: 0.4rem;
    text-align: center;
  }
}
.bg {
  height: 3.6rem;
  background: url("../../../assets/images/area.png") no-repeat;
  background-size: cover;
  padding-top: 2.6rem;
}
.content {
  background: #fff;
  margin-left: 0.2rem;
  margin-right: 0.2rem;
  padding: 0.2rem;
  border-radius: 0.2rem;
  min-height: 4rem;
  margin-bottom: 0.2rem;
  .th {
    position: relative;
    margin-bottom: 0.3rem;
    font-size: 0.4rem;
    letter-spacing: 0.01rem;
    span {
      position: absolute;
      bottom: 0.06rem;
    }
    p::before {
      display: inline-block;
      width: 0.1rem;
      height: 0.4rem;
      margin-right: 0.1rem;
      content: "";
      background-color: #4169e2;
    }
  }
  .title {
    font-size: 0.35rem;
    margin-bottom: 0.3rem;
    margin-top: 0.3rem;
    letter-spacing: 0.01rem;
    img {
      width: 0.4rem;
      vertical-align: middle;
      margin-bottom: 0.1rem;
    }
  }
  .list {
    li {
      font-size: 0.3rem;
      margin-top: 0.2rem;
      padding: 0.1rem;
      background: #f7f7f7;
      border-radius: 0.1rem;
      letter-spacing: 0.01rem;
      line-height: 0.5rem;
    }
  }
}
</style>
